<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ page contentType="text/html" pageEncoding="UTF-8"%>

<tiles:insertDefinition name="baseTemplate">
    <tiles:putAttribute name="title">
        <title>Аккаунт</title>
    </tiles:putAttribute>
        
    <tiles:putAttribute name="selectedItem">
            <input type="hidden" id="menu_selected_item" value="menuitem_account">
    </tiles:putAttribute>    
        
    <tiles:putAttribute name="body">
        <div id="edit_user_container">
            <sec:authorize access="hasAnyRole('ROLE_ADMIN','ROLE_HR','ROLE_MANAGER')">
                <h4>Ваши полномочия:</h4>
                <ul>
                <sec:authorize access="hasRole('ROLE_ADMIN')">
                    <li>Администратор доступа</li>
                </sec:authorize>
                <sec:authorize access="hasRole('ROLE_HR')">
                    <li>HR</li>
                </sec:authorize>
                <sec:authorize access="hasRole('ROLE_MANAGER')">
                    <li>Менеджер</li>
                </sec:authorize>
                </ul>
            </sec:authorize>
            <core:if test="${resultError!=null && resultError}">
                <div>
                    <p>Ошибка, изменения не были приняты</p>
                </div>
            </core:if>
            <core:if test="${resultError!=null && !resultError}">
                <div>
                    <p>Изменения приняты</p>
                </div>
            </core:if>
            <form:form method="POST" commandName="userCommandFormat" action="account">
                <form:hidden path="id"/>
                <form:hidden path="prevLogin"/>
                <table class="table">
                    <tr>
                        <td>Логин: </td>
                        <td><form:input path="login" readonly="true"/> </td>
                        <td><form:errors path="login"/> </td>
                    </tr>
                    <tr>
                        <td>Новый пароль: </td>
                        <td><form:password path="password"/> </td>
                        <td><form:errors path="password"/> </td>
                    </tr>
                    <tr>
                        <td>Повторите пароль: </td>
                        <td><form:password path="confirmPassword"/> </td>
                        <td><form:errors path="confirmPassword"/> </td>
                    </tr>
                    <tr>
                        <td>Предыдущий пароль: </td>
                        <td><form:password path="previousPassword"/> </td>
                        <td><form:errors path="previousPassword"/> </td>
                    </tr>
                    <tr>
                        <td><input id="reset_edit_user" name="reset_edit_user" value="Сброс" type="reset"></td>
                        <td colspan="2"><input id="apply_user_changes" name="apply_user_changes" value="Применить изменения" type="submit"></td>
                    </tr>
                </table>
            </form:form>
                
        </div>
    </tiles:putAttribute>
</tiles:insertDefinition>